import javax.swing.*;
import java.awt.event.*;
public class MyJFrame implements ActionListener
{
    JButton button;

    public static void main(String[] args) {
        MyJFrame gui = new MyJFrame();
        gui.go();
        System.out.println("End");
    }

    public void go() {
        JFrame frame = new JFrame();
        button = new JButton("Click me");

        button.addActionListener(this);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //click "X" to exit program
        frame.getContentPane().add(button);
        frame.setSize(300,300);
        frame.setVisible(true);
    }

    public void actionPerformed(ActionEvent event) {
        static boolean btStatus = true;
        if(btStatus) {
            button.setText("I've been clicked! 111");
            btStatus = false;
        }
        else {
            button.setText("I've been clicked! 222");
            btStatus = true;
        }
    }
}